perm filename BOOK.XGP[LSP,JRA]7 blob
sn#352517 filedate 1978-05-03 generic text, type T, neo UTF8
/LMAR=0/XLINE=4/FONT#0=BASL30/FONT#1=BASB30/FONT#5=ASI30[LSP,JRA]/FONT#2=ASI30[LSP,JRA]/FONT#3=SUB/FONT#4=SET1/FONT#6=GRK30/FONT#7=SUP/FONT#8=SPEC[LSP,JRA]/FONT#9=BUCK75/FONT#10=GRFX25[LSP,JRA]/FONT#11=METSB/FONT#12=NGB30/FONT#13=GERM35/FONT#14=MG[LSP,JRA]/FONT#15=GRFX35
␈↓ α←␈↓␈↓␈↓ ≡CONTENTS i␈↓
␈↓"β␈↓ α←␈↓↓␈↓ ∧aT A B L E O F C O N T E N T S
␈↓"β␈↓ α←␈↓␈↓↓PREFACE␈↓
Ei␈↓
␈↓"β␈↓ α←␈↓␈↓↓CHAPTER␈↓ |PAGE␈↓
␈↓"β␈↓ α←␈↓␈↓↓INDEX␈↓
Fi␈↓
␈↓"β␈↓ α←␈↓␈↓ β'TEXT
␈↓ α←␈↓␈↓␈↓
_ 1␈↓
␈↓"β␈↓ α←␈↓␈↓ β'Now␈α↔to␈α↔the␈α⊗problem␈α↔of␈α↔translating␈α⊗a␈α↔␈↓αprog␈↓␈α↔into␈α↔an␈α⊗S-expression
␈↓ α←␈↓representation: the construct,
␈↓"∀␈↓ α←␈↓␈↓ β'␈↓ ∧P␈↓αprog[[v␈↓β1␈↓α; ...; v␈↓βn␈↓α] ... ]␈↓ will be translated to:
␈↓" ␈↓ α←␈↓␈↓ β'␈↓ ¬E␈↓α(PROG(V1 ... VN) ... )␈↓
␈↓"∀␈↓ α←␈↓The␈α⊃body␈α⊃of␈α⊃the␈α⊃␈↓αprog␈↓␈α⊃must␈α⊃be␈α⊃handled␈α⊃specially␈α⊃by␈α⊃a␈α⊃new␈α⊃piece␈α⊃of␈α⊂the
␈↓ α←␈↓evaluator since ␈↓αprog␈↓ is a special form.
␈↓"β␈↓ α←␈↓␈↓ β'We␈α
must␈α∞also␈α
be␈α∞careful␈α
about␈α
the␈α∞interpretation␈α
of␈α∞←.␈α
We␈α∞will␈α
write
␈↓ α←␈↓␈↓αx ← y␈↓ in prefix form as: ␈↓αsetq[x;y]␈↓. We will map this to:
␈↓"∀␈↓ α←␈↓␈↓ ε␈↓α(SETQ X Y) ␈↓
␈↓"β␈↓ α←␈↓The␈α∞assignment,␈α
␈↓αsetq␈↓,␈α∞is␈α∞also␈α
a␈α∞special␈α
form.␈α∞ For␈α∞if␈α
␈↓αx␈↓␈α∞and␈α
␈↓αy␈↓␈α∞have␈α∞values␈α
␈↓α2␈↓
␈↓ α←␈↓and␈α∞␈↓α3␈↓,␈α∞for␈α∞example,␈α∞then␈α∞the␈α∞call-by-value␈α∞interpretation␈α∞of␈α∂␈↓αsetq[x;y]␈↓␈α∞would
␈↓ α←␈↓say␈α∞␈↓αsetq[2;3]␈↓.␈α∞This␈α∞was␈α
not␈α∞our␈α∞intention.␈α∞ We␈α
want␈α∞to␈α∞evaluate␈α∞the␈α
second
␈↓ α←␈↓argument to ␈↓αsetq␈↓ while stopping the evaluation of the first argument.
␈↓"β␈↓ α←␈↓␈↓ β'LISP␈α
has␈αanother␈α
assignment-like␈α
operator␈αcalled␈α
␈↓αset␈↓.␈α
Both␈αarguments
␈↓ α←␈↓of␈α⊃this␈α⊃binary␈α⊃operator␈α⊃are␈α⊃evaluated;␈α⊃the␈α⊃value␈α⊃of␈α⊃the␈α⊃first␈α⊃argument␈α⊂is
␈↓ α←␈↓expected␈α⊃to␈α⊃be␈α⊃a␈α⊃representation␈α⊃of␈α⊂a␈α⊃variable;␈α⊃that␈α⊃is,␈α⊃the␈α⊃first␈α⊂argument
␈↓ α←␈↓evaluates␈αto␈αa␈αliteral␈αatom.␈α The␈αsecond␈αargument␈αis␈αa␈αLISP␈αform␈αand␈αusing
␈↓ α←␈↓the␈αvalue␈αof␈αthat␈αform,␈αan␈αassignment␈αis␈αmade␈αto␈αthe␈αvariable␈αrepresented␈αby
␈↓ α←␈↓the first argument. Thus ␈↓αsetq[x;y]␈↓ is synonymous with ␈↓αset[quote[x];y]␈↓.
␈↓"β␈↓ α←␈↓␈↓ β'As␈α∞a␈α∞more␈α∞complex␈α∞example,␈α∞consider␈α∞␈↓αset[z;␈α∞plus[x;1]]␈↓.␈α∞ If␈α∞the␈α
current
␈↓ α←␈↓value␈α∀of␈α∀variable␈α∀␈↓αz␈↓␈α∀is␈α∀an␈α∀identifier,␈α∀then␈α∀␈↓αset[z;␈α∀plus[x;1]]␈↓␈α∃makes␈α∀sense.
␈↓ α←␈↓Assume␈αthe␈αcurrent␈αvalue␈αof␈α
␈↓αz␈↓␈αis␈α␈↓αA␈↓;␈αand␈αassume␈α
the␈αcurrent␈αvalue␈αof␈α␈↓αx␈↓␈α
is␈α␈↓α2␈↓;
␈↓ α←␈↓since␈α␈↓αA␈↓␈αrepresents␈αthe␈αidentifier␈α␈↓αa␈↓,␈αthe␈αeffect␈αof␈αthe␈α␈↓αset␈↓␈αstatement␈αis␈αto␈αassign
␈↓ α←␈↓the␈α
value␈α␈↓α3␈↓␈α
to␈α
␈↓αa␈↓.␈α Normally␈α
when␈α
making␈αassignments,␈α
we␈α
want␈αto␈α
assign␈αto␈α
a
␈↓ α←␈↓␈↓¬name␈↓ and not a ␈↓¬value␈↓; thus we will tend to use the ␈↓αsetq␈↓ form.
␈↓"β␈↓ α←␈↓␈↓ β'Finally, here is a translation of the body of the ␈↓αprog␈↓ version of ␈↓αlength:␈↓ ␈↓α
␈↓"∀␈↓ α←␈↓α␈↓ β'(LAMBDA␈↓ ∧C(L)
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C(PROG (L1 C)
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C␈↓ ∧s(SETQ L1 L)
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C␈↓ ∧s(SETQ C 0)
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧CA␈↓ ∧s(COND ((NULL L1) (RETURN C)))
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C␈↓ ∧s(SETQ C (ADD1 C))
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C␈↓ ∧s(SETQ L1 (REST L1))
␈↓"β␈↓ α←␈↓α␈↓ β'␈↓ ∧C␈↓ ∧s(GO A) ))
␈↓ α←␈↓␈↓␈↓ KINDEX 3␈↓
␈↓ α←␈↓␈↓ Index␈↓